home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _CE04A7280CC84D2993FD96B1299934CF < prev    next >
Encoding:
Text File  |  2004-01-06  |  3.3 KB  |  131 lines

  1. UI.PageCutScenePlayer=
  2. {    
  3.     GUI=
  4.     {
  5.         CutScene =
  6.         {
  7.             classname = "videopanel",
  8.             
  9.             left = 0, top = 0,
  10.             width = 800, height = 600,
  11.             
  12.             color = "0 0 0 255",
  13.  
  14.             zorder = 1000,
  15.             
  16.             bordersize = 0,
  17.             tabstop = 1,
  18.             
  19.             looping = 0,
  20.             keepaspect = 1,            
  21.         
  22.             OnError = function(Sender, szErrorString)
  23.                 UI.PageCutScenePlayer:Finished();
  24.             end,
  25.             
  26.             OnFinished = function(Sender)
  27.                 UI.PageCutScenePlayer:Finished();
  28.             end
  29.         },
  30.  
  31.         OnUpdate = function(Sender)
  32.             
  33.             local bPlaying = UI.PageCutScenePlayer.GUI.CutScene:IsPlaying();
  34.             
  35.             if ((not bPlaying) or (tonumber(bPlaying) == 0)) then
  36.                 UI:StopCutScene();
  37.                 
  38.                 return;
  39.             end
  40.  
  41.             if (UI.PageCutScenePlayer.bCanSkip and tonumber(UI.PageCutScenePlayer.bCanSkip) ~= 0) then
  42.                 local szKeyName = Input:GetXKeyPressedName();
  43.             
  44.                 if ((szKeyName == "esc") or (szKeyName == "spacebar") or (szKeyName == "rmb") or (szKeyName == "lmb")) then
  45.                     UI:StopCutScene();
  46.                 end
  47.             end
  48.         end,
  49.  
  50.         OnActivate= function(Sender)
  51.             if (UI.PageCutScenePlayer.szCutSceneName) then
  52.                 local szCutSceneName = UI.PageCutScenePlayer.szCutSceneName;
  53.             
  54.                 UI:HideMouseCursor();
  55.                     
  56.                 UI.PageCutScenePlayer.GUI.CutScene:LoadVideo(szCutSceneName, 1);
  57.                 UI.PageCutScenePlayer.GUI.CutScene:Play();
  58.             end
  59.  
  60.             UI.PageCutScenePlayer.szCutSceneName = nil;            
  61.         end,
  62.         
  63.         OnDeactivate = function(Sender)
  64.             UI:ShowMouseCursor();
  65.             
  66.             local bPlaying = UI.PageCutScenePlayer.GUI.CutScene:IsPlaying();
  67.                         
  68.             UI.PageCutScenePlayer.GUI.CutScene:ReleaseVideo();
  69.             
  70.             if (bPlaying) then
  71.                 UI.PageCutScenePlayer:Finished();
  72.             end
  73.             
  74.             if (UI.PageCutScenePlayer.szGotoPage) then
  75.                 GotoPage(UI.PageCutScenePlayer.szGotoPage, UI.PageCutScenePlayer.bGotoPageShowBack);
  76.             end
  77.             UI:SetFocus(Sender.CutScene);
  78.         end
  79.     },    
  80. };
  81.  
  82. function UI.PageCutScenePlayer:Finished()
  83.  
  84.     Game:HideMenu();
  85.     
  86.     UI.bInGameOverride = nil;
  87.     UI:DeactivateScreen("CutScenePlayer");
  88.     
  89.     if (UI.PageCutScenePlayer.szMessage and strlen(UI.PageCutScenePlayer.szMessage)) then
  90.         Game:SendMessage(UI.PageCutScenePlayer.szMessage);
  91.     elseif (UI.PageCutScenePlayer.pfnFunction) then
  92.         UI.PageCutScenePlayer.pfnFunction();
  93.     end
  94. end
  95.  
  96. UI:CreateScreenFromTable("CutScenePlayer", UI.PageCutScenePlayer.GUI);
  97.  
  98. function UI:PlayCutScene(szCutSceneName, szMessage, szGotoPage, bGotoPageShowBack)
  99.     UI:PlayCutSceneEx(szCutSceneName, szMessage, szGotoPage, bGotoPageShowBack, 1);
  100. end
  101.  
  102. function UI:PlayCutSceneEx(szCutSceneName, szMessage, szGotoPage, bGotoPageShowBack, bCanSkip)
  103.  
  104.     if (UI.MusicId ~= nil) then
  105.         Sound:StopSound(UI.MusicId);
  106.     end
  107.  
  108.     UI.bInGameOverride = 1; -- don't use the current ingame menu
  109.  
  110.     Game:ShowMenu();
  111.  
  112.     UI.PageCutScenePlayer.szCutSceneName = szCutSceneName;
  113.     UI.PageCutScenePlayer.szGotoPage = szGotoPage;
  114.     UI.PageCutScenePlayer.bGotoPageShowBack = bGotoPageShowBack;
  115.     UI.PageCutScenePlayer.bCanSkip = bCanSkip;
  116.  
  117.     if (type(szMessage) == "function") then
  118.         UI.PageCutScenePlayer.pfnFunction = szMessage;
  119.         UI.PageCutScenePlayer.szMessage = nil;
  120.     else
  121.         UI.PageCutScenePlayer.szMessage = szMessage;
  122.         UI.PageCutScenePlayer.pfnFunction = nil;
  123.     end
  124.  
  125.     UI:DeactivateAllScreens();
  126.     UI:ActivateScreen("CutScenePlayer");
  127. end
  128.  
  129. function UI:StopCutScene()
  130.     UI:DeactivateScreen("CutScenePlayer");
  131. end